# coding: utf-8
from sqlalchemy import CHAR, Column, JSON, String, TIMESTAMP, Table, Text, text, MetaData
from sqlalchemy.dialects.mysql import ENUM, INTEGER, LONGTEXT, MEDIUMINT, MEDIUMTEXT, TEXT, TINYINT, VARCHAR
from ..database import db,serialize



class Category(db.Model):
    __tablename__ = 'categorys'

    id = Column(INTEGER(11), primary_key=True)
    parentid = Column(INTEGER(11), nullable=False)
    arrparentid = Column(String(255, 'utf8mb4_unicode_ci'), nullable=False, server_default=text("'0'"))
    child = Column(TINYINT(4), nullable=False)
    arrchildid = Column(Text(collation='utf8mb4_unicode_ci'), nullable=False)
    name = Column(String(50, 'utf8mb4_unicode_ci'), nullable=False)
    thumb = Column(String(255, 'utf8mb4_unicode_ci'))
    title = Column(String(255, 'utf8mb4_unicode_ci'), comment='标题')
    keyword = Column(String(255, 'utf8mb4_unicode_ci'), comment='关键字')
    describe = Column(Text(collation='utf8mb4_unicode_ci'))
    content = Column(Text(collation='utf8mb4_unicode_ci'))
    cate_tpl = Column(String(50, 'utf8mb4_unicode_ci'), nullable=False, server_default=text("'list'"), comment='模板')
    art_tpl = Column(String(50, 'utf8mb4_unicode_ci'), nullable=False, server_default=text("'show'"), comment='文章模板')
    display = Column(TINYINT(4), nullable=False, server_default=text("'1'"), comment='1显示，0不显示')
    type = Column(TINYINT(1), nullable=False, server_default=text("'0'"))
    sort = Column(MEDIUMINT(8), nullable=False, server_default=text("'0'"))
    url = Column(CHAR(50, 'utf8mb4_unicode_ci'), nullable=False, index=True)
    created_at = Column(TIMESTAMP)
    updated_at = Column(TIMESTAMP)
